package fr.univtln.superplanning.test.ressources;

import fr.univtln.superplanning.api.ISuperplanningManager;
import fr.univtln.superplanning.api.SuperplanningManagerDB;
import fr.univtln.superplanning.exceptions.NegativeNumberException;
import fr.univtln.superplanning.persistence.DBLogin;
import fr.univtln.superplanning.persistence.DatabaseManager;

/**
 * This class contains static constants for test functions.
 * 
 * @author vincent
 * 
 */
public class DatabaseRessources {

	public static final String PROTOCOLE = "postgresql";
	public static final int PORT = 5432;
	public static final String HOST = "localhost";
	public static final String LOGIN = "**";
	public static final String PASSWORD = "***";
	public static final String DATABASE_NAME = "Superplanning";

	private static DBLogin dbLogin = DatabaseManager.getDbLogin();
	private static ISuperplanningManager superplanningManager = new SuperplanningManagerDB();

	static {
		try {
			dbLogin.setDatabaseName(DatabaseRessources.DATABASE_NAME);
			dbLogin.setHost(DatabaseRessources.HOST);
			dbLogin.setPort(DatabaseRessources.PORT);
			dbLogin.setProtocole(DatabaseRessources.PROTOCOLE);
			dbLogin.setUserName(DatabaseRessources.LOGIN);
			dbLogin.setPassword(DatabaseRessources.PASSWORD);

			dbLogin.login();

		} catch (NegativeNumberException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static DBLogin getDbLogin() {
		return dbLogin;
	}

	public static ISuperplanningManager getSuperplanningManager() {
		return superplanningManager;
	}

	public static void setSuperplanningManager(ISuperplanningManager superplanningManager) {
		DatabaseRessources.superplanningManager = superplanningManager;
	}

	public static void setDbLogin(DBLogin dbLogin) {
		DatabaseRessources.dbLogin = dbLogin;
	}
}
